<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1, maximum-
scale=1">
      <title>Title</title>
      <link rel="stylesheet" href="/resources/layui/css/layui.css" media="all" />
</head>
<body>
<input type="hidden" id="userId" value="111">
<table class="layui-hide" id="roleTable" lay-filter="roleTable"></table>
<script type="text/javascript" src="/resources/layui/layui.js"></script>
<script th:inline="none">
    //一般直接写在一个js文件中
    layui.use(['layer', 'form','table'], function(){
        var layer = layui.layer
            ,form = layui.form
            ,$=layui.jquery
            ,table = layui.table;
        //使用表格
        var roleTable=table.render({
            elem:'#roleTable',
            height:180,
            url:'/role/roleList',
            where:{
                uid:$("#userId").val()
            },
            id:'roleListTable',
            done:function (res) {
                if(res.code==111){
                    layer.msg(res.message);
                }
            },
            cols:[[
                {field: 'id', title: '编号', width:80,type:"checkbox"},
                {field: 'name', title: '角色名称'}
            ]]
        });
    });
    //回调函数
    var callbackdata=function () {
        var checkStatus=layui.table.checkStatus('roleListTable');
        return checkStatus.data;
    };
</script>
</body>
</html>